#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int min_left (int a[], const int size)
{int left;
for(int i=0;i<size;i++)
{
	if(a[i]<0)
	{
	left=i;
	return left;
	}
}
cout<<"Eroor";
return -1;
}

int min_right (int a[], const int size)
{int right;
	for(int j=size-1;j>0;j--)
	{
		if(a[j]<0)
		{
		right=j;
		return right;
		}
	}
cout<<"Eroor";
return -1;
}

void sort (int a[], const int size,int left,int right)
{int x;
	for(int i=left+1;i<size;i++)
	{
		for(int j=right-1;j>i;j--)
		{ 
			
			if(a[j-1]>a[j])
			{
			x=a[j-1];
			a[j-1]=a[j];
			a[j]=x;
			}
		}
	}
}
void main()
{ 
	srand(time(NULL));
	const int size=40;
	int a[size];
	int left,right;
	for(int i=0;i<size;i++)
	{
			a[i]=rand()%21+(-rand()%21);
			cout<<a[i]<<" ";
	}cout<<endl;
	left=min_left(a,size);
	cout<<" number of left negative element : "<<left;
	cout<<endl;
	right=min_right(a,size);
	cout<<"number of right negative element : "<<right;
	cout<<endl;
		sort(a,size,left,right);
		cout<<"\n";
		for(int i=0;i<size;i++)
		{cout<<a[i]<<" ";}
	
}